package com.byxm.wlgw.control.admin;

import java.util.List;

import com.byxm.wlgw.bean.KcxxBean;
import com.byxm.wlgw.bean.SpxhBean;
import com.byxm.wlgw.bean.SpxxBean;
import com.byxm.wlgw.control.BaseAction;
import com.byxm.wlgw.service.KcxxService;
import com.byxm.wlgw.service.SpxhService;
import com.byxm.wlgw.service.SpxxService;

public class Kcxx_glAction extends BaseAction{
	private static final long serialVersionUID = 1L;
	SpxhService spxhService=new SpxhService();
	KcxxService kcxxService=new KcxxService();
	SpxxService spxxService=new SpxxService();
	private SpxxBean spxxBean;
	//型号list
	private List<SpxhBean> lstSpxh;
	//库存信息list
	private List<KcxxBean> lstKcxx;
	
	//库存信息 保存时使用
	private KcxxBean kcxxBean;
	
	/**
	 * 查看信息
	 * @return
	 */
	public String list(){
		try {
			//通过商品大类别查出商品型号的信息
			lstSpxh=spxhService.getSpxh(spxxBean.getSplbfid());
			//库存信息
			lstKcxx=kcxxService.getLstKcxx(spxxBean.getSpxxid());
			for(int i=0;i<lstKcxx.size();i++){
				for(int j=0;j<lstSpxh.size();j++){
					if(lstKcxx.get(i).getXhid()==lstSpxh.get(j).getXhid()){
						lstSpxh.remove(j);
					}
				}
			}
			spxxBean=spxxService.getSpxxByspxxid(spxxBean.getSpxxid());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return "success_01";
	}
	
	/**
	 * 保存  库存信息
	 * @return
	 */
	public String save(){
		try {
			//增加某一个型号的库存
			kcxxService.saveKcxx(kcxxBean);
			//更新商品中的总库存 暂时这么做
			spxxService.updateKcsl(kcxxBean);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return "success_02";
	}
	

	
	/***setter getter****/
	public SpxxBean getSpxxBean() {
		return spxxBean;
	}
	public void setSpxxBean(SpxxBean spxxBean) {
		this.spxxBean = spxxBean;
	}
	public List<SpxhBean> getLstSpxh() {
		return lstSpxh;
	}
	public void setLstSpxh(List<SpxhBean> lstSpxh) {
		this.lstSpxh = lstSpxh;
	}

	public List<KcxxBean> getLstKcxx() {
		return lstKcxx;
	}

	public void setLstKcxx(List<KcxxBean> lstKcxx) {
		this.lstKcxx = lstKcxx;
	}

	public KcxxBean getKcxxBean() {
		return kcxxBean;
	}

	public void setKcxxBean(KcxxBean kcxxBean) {
		this.kcxxBean = kcxxBean;
	}
	
	
	
}
